import cv2
import numpy as np
def detectAndDescribe(image):
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    orb = cv2.ORB_create()
    kp, des = orb.detectAndCompute(gray, None)
    return image, kp, des
imgA = cv2.imread('left_01.jpg')
imgB = cv2.imread('right_01.jpg')

imgA, kpA, desA = detectAndDescribe(imgA)
imgB, kpB, desB = detectAndDescribe(imgB)

bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=False)
rawMatches = bf.knnMatch(desA, desB, k=2)

ratio = 0.7
matches = [[m] for m, n in rawMatches if m.distance < ratio * n.distance]
out = cv2.drawMatchesKnn(imgA, kpA, imgB, kpB, matches[:50], None, flags=cv2.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)
cv2.imshow('ORB + BFMatcher', out)
cv2.waitKey()
cv2.destroyAllWindows()